#include "Helper.h"
///-----------------------------------------------------------------------------
Helper::Helper(void)
{

}
///-----------------------------------------------------------------------------
Helper::~Helper(void)
{

}
///-----------------------------------------------------------------------------
void Helper::SplitByChar(const std::string& sz, std::vector<std::string>& output_vector,const char ch)
{
	std::istringstream is(sz);
	std::string sztmp;
	while (getline(is, sztmp, ch))
	{  
		if (sztmp == "")  
		{   
			continue;  
		}  
		output_vector.push_back(sztmp); 
	}
}
///-----------------------------------------------------------------------------
bool Helper::Match(const char* pattern, const char* content)
{
	if ('\0' == *pattern && '\0' == *content)
	{
		return true;
	}
	if ('*' == *pattern && '\0' != *(pattern + 1) && '\0' == *content)
	{
		return false;
	}
	if ('?' == *pattern || *pattern == *content)
	{
		return Match(pattern + 1, content + 1);
	}
	if ('*' == *pattern)
	{
		return Match(pattern + 1, content) || Match(pattern, content + 1);
	}
	return false;
}
///-----------------------------------------------------------------------------
struct Time Helper::transferTime(time_t time)
{
	tm tmTemp;
	localtime_s(&tmTemp, &time);

	Time structTime;

	structTime.m_nYear = tmTemp.tm_year;
	structTime.m_nMonth = tmTemp.tm_mon;
	structTime.m_nDay = tmTemp.tm_mday;
	structTime.m_nHour = tmTemp.tm_hour;
	structTime.m_nMinute = tmTemp.tm_min;
	structTime.m_nSecond = tmTemp.tm_sec;

	return structTime;
}
//-----------------------------------------------------------------------------
void Helper::MyGetCurrentTime(Time& currentTime)
{
	time_t now = time(NULL);
	tm tmNow;
	localtime_s(&tmNow, &now);
	currentTime.m_nYear = tmNow.tm_year;
	currentTime.m_nMonth = tmNow.tm_mon;
	currentTime.m_nDay = tmNow.tm_mday;
	currentTime.m_nHour = tmNow.tm_hour;
	currentTime.m_nMinute = tmNow.tm_min;
	currentTime.m_nSecond = tmNow.tm_sec;
}
//-----------------------------------------------------------------------------